from permutations import permutations, selections
from digits import digits, rdigits
from primes import PrimeChecker, prime


checker = PrimeChecker(10000)
generator = prime()

for p in generator:
    if p < 1000: continue;
    if p >= 10000: break;

    d = digits(p)
    p = set([rdigits(x) for x in permutations(d)])
    q = [x for x in p if checker.is_prime(x)]

    for s in selections(q, 3):
        s.sort()
        if s[1] - s[0] == s[2] - s[1]:
            print s
